#ifndef Tui_TTab_h
#define Tui_TTab_h

#include "TBase.h"
#include "TButton.h" 

using namespace rapidxml;

class TTab:public TPanel{
    
public: 
    
    CREATE_FUNC(TTab);
    ~TTab();
    TTab();
    
    static TTab* create(xml_node<> * pItem);
    virtual  void initWidthConf(xml_node<> * pItem); 
    virtual void onCreateComplete();
    
    TPanel* getCurPanel();
    TButton* getCurTButton();
    void setTabChangeTarget(CCObject*  m_pListener,SEL_MenuHandler    m_pfnSelector);
    void changeTab(int tag);
    void changeIdx(int idx);
    TButton* getBtnByTag(int tag);
protected:
    
    TPanel* m_pCurPanel;
    TButton* m_pCurBtn;
    CCObject*       m_pListener;
    SEL_MenuHandler    m_pfnSelector;
    vector<TButton*> gBtns;
    vector<TPanel*>  gPanels;
    void onBtnClick(CCObject*);
    void selectBtn(TButton* btn);
    void clear();
};

#endif
